package com.sinitek.web.controller;

import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: elastic
 * @description:
 * @author: Mr.chen
 * @create: 2019-04-26 13:44
 */
//@Api(tags = "帐号相关接口")
//@RestController
//@RequestMapping("account")
public class BackController {

//    //索引名称(数据库名)
//    private String indexName = "bank";
//    //类型名称(表名)
//    private String type = "account";
//
//    @Autowired
//    private AccountService accountService;
//
//    @ApiOperation(value = "保存文档")
//    @PostMapping("/save")
//    public ApiResult save(@RequestBody Account account) {
//        Object result = accountService.save(account, indexName, type);
//        if (result == null) {
//            return R.error(ApiResultEnum.SUCCESS.getCode(), ApiResultEnum.OPERATE_FAIL.getMsg());
//        }
//        return R.success(result);
//    }
//
//    @ApiOperation(value = "更新文档")
//    @PutMapping("/{id}")
//    public ApiResult update(@RequestBody Account account,
//                            @ApiParam(name = "id", value = "文档编号", required = true) @PathVariable("id") String id) {
//        Object result = accountService.update(account, indexName, type, id);
//        if (result == null) {
//            return R.error(ApiResultEnum.SUCCESS.getCode(), ApiResultEnum.OPERATE_FAIL.getMsg());
//        }
//        return R.success(result);
//    }
//
//    @ApiOperation(value = "通过编号获取文档")
//    @GetMapping("/{id}")
//    public ApiResult get(@ApiParam(name = "id", value = "文档编号", required = true) @PathVariable("id") String id) {
//        Object result = accountService.findById(indexName, type, id);
//        return R.success(result);
//    }
//
//    @ApiOperation(value = "通过编号删除文档")
//    @DeleteMapping("/{id}")
//    public ApiResult findById(@ApiParam(name = "id", value = "文档编号", required = true) @PathVariable("id") String id) {
//        Boolean result = accountService.deleteById(indexName, type, id);
//        if (!result) {
//            return R.error(ApiResultEnum.SUCCESS.getCode(), ApiResultEnum.OPERATE_FAIL.getMsg());
//        }
//        return R.success();
//    }
//
//    @ApiOperation(value = "索引查询通过字段全文查询")
//    @PostMapping("/findAllMatch")
//    public ApiResult findAllMatch(@RequestBody FindAllMatchRequest findAllMatchRequest) {
//        Page<Map<String, Object>> result = accountService.findAllMatch(indexName,
//                findAllMatchRequest.getSortFieldName(),
//                findAllMatchRequest.getSortOrder(),
//                findAllMatchRequest.getBasePageRequest());
//        return R.success(result);
//    }
//
//    @ApiOperation(value = "关键词查询(单一字段匹配) (模糊匹配)")
//    @PostMapping("/findAllMatchByKeyword")
//    public ApiResult findAllMatchByKeyword(@RequestBody FindAllMatchByKeywordRequest findAllMatchByKeywordRequest) {
//        Page<Map<String, Object>> result = accountService.findAllMatchByKeyword(indexName,
//                findAllMatchByKeywordRequest.getSortFieldName(),
//                findAllMatchByKeywordRequest.getSortOrder(),
//                findAllMatchByKeywordRequest.getSearchFieldName(),
//                findAllMatchByKeywordRequest.getBasePageRequest(),
//                findAllMatchByKeywordRequest.getKeyWord());
//        return R.success(result);
//    }
//
//    @ApiOperation(value = "多关键词匹配某一字段查询 (分词精确查询)")
//    @PostMapping("/findAllTermsByKeywords")
//    public ApiResult findAllTermsByKeywords(@RequestBody FindAllTermsByKeywordsRequest findAllTermsByKeywords) {
//        Page<Map<String, Object>> result = accountService.findAllTermsByKeywords(indexName,
//                findAllTermsByKeywords.getSortFieldName(),
//                findAllTermsByKeywords.getSortOrder(),
//                findAllTermsByKeywords.getSearchFieldName(),
//                findAllTermsByKeywords.getBasePageRequest(),
//                findAllTermsByKeywords.getKeyWords().toLowerCase().split(","));
//        return R.success(result);
//    }
//
//    @ApiOperation(value = "前缀关键词查询 Gar (模糊匹配)")
//    @PostMapping("/findAllByPrefix")
//    public ApiResult findAllByPrefix(@RequestBody FindAllByPrefixRequest findAllByPrefixRequest) {
//        Page<Map<String, Object>> result = accountService.findAllByPrefix(indexName,
//                findAllByPrefixRequest.getSortFieldName(),
//                findAllByPrefixRequest.getSortOrder(),
//                findAllByPrefixRequest.getBasePageRequest(),
//                findAllByPrefixRequest.getSearchFieldName(),
//                findAllByPrefixRequest.getPrefix().toLowerCase());
//        return R.success(result);
//    }
//
//    @ApiOperation(value = "多字段匹配关键词查询 (模糊匹配)")
//    @PostMapping("/findAllMultiMatchByKeywords")
//    public ApiResult findAllMultiMatchByKeywords(@RequestBody FindAllMultiMatchByKeywordsRequest findAllMultiMatchByKeywordsRequest) {
//        Page<Map<String, Object>> result = accountService.findAllMultiMatchByKeywords(indexName,
//                findAllMultiMatchByKeywordsRequest.getSortFieldName(),
//                findAllMultiMatchByKeywordsRequest.getSortOrder(),
//                findAllMultiMatchByKeywordsRequest.getKeyWord().toLowerCase(),
//                findAllMultiMatchByKeywordsRequest.getBasePageRequest(),
//                findAllMultiMatchByKeywordsRequest.getSearchFieldNames().split(","));
//        return R.success(result);
//    }
//
//
//    @ApiOperation(value = "重要 - 范围查询包含(模糊匹配)")
//    @PostMapping("/findAllRangeIncludeByCondition")
//    public ApiResult findAllRangeIncludeByCondition(@RequestBody FindAllRangeIncludeByConditionRequest findAllRangeIncludeByConditionRequest) {
//        Page<Map<String, Object>> result = accountService.findAllRangeIncludeByCondition(indexName,
//                findAllRangeIncludeByConditionRequest.getSortFieldName(),
//                findAllRangeIncludeByConditionRequest.getSortOrder(),
//                findAllRangeIncludeByConditionRequest.getBasePageRequest(),
//                findAllRangeIncludeByConditionRequest.getSearchFieldName(),
//                findAllRangeIncludeByConditionRequest.getFrom(),
//                findAllRangeIncludeByConditionRequest.getTo());
//        return R.success(result);
//    }
//
//    @ApiOperation(value = "重要 - 范围查询不包含 (模糊匹配)")
//    @PostMapping("/findAllRangeUnIncludeByCondition")
//    public ApiResult findAllRangeUnIncludeByCondition(@RequestBody FindAllRangeUnIncludeByConditionRequest findAllRangeUnIncludeByConditionRequest) {
//        Page<Map<String, Object>> result = accountService.findAllRangeUnIncludeByCondition(indexName,
//                findAllRangeUnIncludeByConditionRequest.getSortFieldName(),
//                findAllRangeUnIncludeByConditionRequest.getSortOrder(),
//                findAllRangeUnIncludeByConditionRequest.getBasePageRequest(),
//                findAllRangeUnIncludeByConditionRequest.getSearchFieldName(),
//                findAllRangeUnIncludeByConditionRequest.getFrom(),
//                findAllRangeUnIncludeByConditionRequest.getTo());
//        return R.success(result);
//    }
//
//    @ApiOperation(value = "重要 - 组合查询(精准匹配)")
//    @PostMapping("/findAllAssociationByCondition")
//    public ApiResult findAllAssociationByCondition(@RequestBody FindAllAssociationByConditionRequest findAllAssociationByConditionRequest) {
//        Page<Map<String, Object>> result = accountService.findAllAssociationByCondition(indexName,
//                findAllAssociationByConditionRequest.getSortFieldName(),
//                findAllAssociationByConditionRequest.getSortOrder(),
//                findAllAssociationByConditionRequest.getBasePageRequest(),
//                findAllAssociationByConditionRequest.getMustQuery(),
//                findAllAssociationByConditionRequest.getMustNotQuery(),
//                findAllAssociationByConditionRequest.getShouldQuery());
//        return R.success(result);
//    }
//
//    @ApiOperation(value = "重要 - 关键词模糊查询 (模糊匹配)")
//    @PostMapping("/findAllFuzzyByKeyWord")
//    public ApiResult findAllFuzzyByKeyWord(@RequestBody FindAllFuzzyByKeyWordRequest findAllFuzzyByKeyWordRequest) {
//        Page<Map<String, Object>> result = accountService.findAllFuzzyByKeyWord(indexName,
//                findAllFuzzyByKeyWordRequest.getSortFieldName(),
//                findAllFuzzyByKeyWordRequest.getSortOrder(),
//                findAllFuzzyByKeyWordRequest.getBasePageRequest(),
//                findAllFuzzyByKeyWordRequest.getSearchFieldName(),
//                findAllFuzzyByKeyWordRequest.getKeyWord());
//        return R.success(result);
//    }
//
//    @ApiOperation(value = "重要 - 关键词通配符查询 * (模糊匹配)")
//    @PostMapping("/findAllWildcardByKeyWord")
//    public ApiResult findAllWildcardByKeyWord(@RequestBody FindAllWildcardByKeyWordRequest findAllWildcardByKeyWordRequest) {
//        Page<Map<String, Object>> result = accountService.findAllWildcardByKeyWord(indexName,
//                findAllWildcardByKeyWordRequest.getSortFieldName(),
//                findAllWildcardByKeyWordRequest.getSortOrder(),
//                findAllWildcardByKeyWordRequest.getBasePageRequest(),
//                findAllWildcardByKeyWordRequest.getSearchFieldName(),
//                findAllWildcardByKeyWordRequest.getKeyWord());
//        return R.success(result);
//    }
//
//    @ApiOperation(value = "分词精确查询(Object类型)")
//    @PostMapping("/findAllCommonTermsByKeywords")
//    public ApiResult findAllCommonTermsByKeywords(@RequestBody FindAllCommonTermsByKeywordsRequest findAllCommonTermsByKeywordsRequest) {
//        Page<Map<String, Object>> result = accountService.findAllCommonTermsByKeywords(indexName,
//                findAllCommonTermsByKeywordsRequest.getSortFieldName(),
//                findAllCommonTermsByKeywordsRequest.getSortOrder(),
//                findAllCommonTermsByKeywordsRequest.getSearchFieldName(),
//                findAllCommonTermsByKeywordsRequest.getBasePageRequest(),
//                findAllCommonTermsByKeywordsRequest.getKeyWord());
//        return R.success(result);
//    }

}
